<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Repositories\Services\IMessage;
use App\Http\Requests\Api\MobileInputDTO;
use App\Util\ResultsVo;
use Illuminate\Support\Facades\Lang;

class MessageController extends Controller
{

    public $messageService;

    public function __construct(IMessage $messageService)
    {
        $this->messageService = $messageService;
    }

    public function send(MobileInputDTO $inputDTO) {
        $valid = rand(1000,9999);
        $params = ['code' => "$valid"];
        $this->messageService->send($inputDTO->get('mobile'), $params, 'Verification');
        return response()->json(new ResultsVo(['message'=>Lang::get('response.success')]));
    }

}